package com.xywy.bloodandroid.bean;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;

/**
 * *****************************************
 * 
 * @Title: User.java
 * @Package com.xywy.bloodandroid.bean
 * @Description: TODO(用户信息存在本地)
 * @author smz
 * @date 2014-12-23 上午11:08:10
 * @version V1.0
 ******************************************* 
 */
public class User extends BaseHttpResponse {

	private static User user = null;
	private int state;
	private String userid;
	private String isregister;
	private String phonenum;
	private String height;
	private String sex;
	private String birthday;
	private String accountstr;
	private String weight;
	private String name;
	private String password;
	private static SharedPreferences sp;// 将登录信息存到文件中
	
	private String avatar ;
	
	
	private boolean is_log_sucess;//是否登录成功

	public boolean getIs_log_sucess() {
		return sp.getBoolean("is_log_sucess", false);
	}

	public void setIs_log_sucess(boolean is_log_sucess) {
		sp.edit().putBoolean("is_log_sucess", is_log_sucess).commit();
	}

	public static User getInstance(Context context) {
		if (user == null) {
			user = new User();
		}
		sp = context.getSharedPreferences("xywy_blood_info",
				Activity.MODE_PRIVATE);
		return user;
	}
	
	public static void setUser(User user){
		User.user = user;
	}

	public int getState() {
		return sp.getInt("state", -1);
	}

	public void setState(int state) {
		System.out.println("这个是返回来的state=="+state);
		sp.edit().putInt("state", state).commit();
	}

	public String getUserid() {
		return sp.getString("userid", "");
	}

	public void setUserid(String userid) {
		System.out.println(userid);
		sp.edit().putString("userid", userid).commit();
	}

	public String getIsregister() {
		return sp.getString("isregister", "");
	}

	public void setIsregister(String isregister) {
		sp.edit().putString("isregister", isregister).commit();
	}

	public String getPhonenum() {
		return sp.getString("phonenum", "");
	}

	public void setPhonenum(String phonenum) {
		sp.edit().putString("phonenum", phonenum).commit();
	}

	public String getHeight() {
		return sp.getString("height", "");
	}

	public void setHeight(String height) {
		sp.edit().putString("height", height).commit();
	}

	public String getWeight() {
		return sp.getString("weight", "");
	}

	public void setName(String name) {
		sp.edit().putString("name", name).commit();
	}

	public String getName() {
		return sp.getString("name", "");
	}

	public void setWeight(String weight) {
		sp.edit().putString("weight", weight).commit();
	}

	public String getSex() {
		return sp.getString("sex", "");
	}

	public void setSex(String sex) {
		sp.edit().putString("sex", sex).commit();
	}

	public String getBirthday() {
		return sp.getString("birthday", "");
	}

	public void setBirthday(String birthday) {
		sp.edit().putString("birthday", birthday).commit();
	}

	public String getAccountstr() {
		return sp.getString("accountstr", "");
	}

	public void setAccountstr(String accountstr) {
		sp.edit().putString("accountstr", accountstr).commit();
	}

	public String getPassword() {
		return sp.getString("password", "");
	}

	public void setPassword(String password) {
		sp.edit().putString("password", password).commit();
	}
	
	
	
	
	
	
	
	

	public String getAvatar() {
		return sp.getString("avatar", "");
	}

	public void setAvatar(String avatar) {
		sp.edit().putString("avatar", avatar).commit();
	}

	@Override
	public String toString() {
		return "User [state=" + state + ", userid=" + userid + ", isregister="
				+ isregister + ", phonenum=" + phonenum + ", height=" + height
				+ ", sex=" + sex + ", birthday=" + birthday + ", accountstr="
				+ accountstr + ", weight=" + weight + ", name=" + name
				+ ", password=" + password + "]";
	}

}
